package com.nyist.zk.service.impl;

import com.nyist.zk.dao.PatientDao;
import com.nyist.zk.entities.Patient;
import com.nyist.zk.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.beans.Transient;
import java.util.List;

@Service
public class PatientServiceImpl implements PatientService {

    @Autowired
    private PatientDao patientDao;

    @Override
    public boolean getPatientByIdAndPassword(Integer p_id, String p_password) {
        Patient patient = patientDao.getPatientByIdAndPassword(p_id, p_password);
        if (patient != null) {
            return true;
        }
        return false;
    }

    @Override
    public List<Patient> findAllPatient() {
        return patientDao.findAllPatient();
    }

    @Override
    public List<Patient> adminFindPatientByNameLike(String p_name) {
        return patientDao.adminFindPatientByNameLike(p_name);
    }

    @Override
    public List<Patient> doctorFindPatientByNameLike(Integer p_doctor, String p_name) {
        return patientDao.doctorFindPatientByNameLike(p_doctor,p_name);
    }

    @Override
    public Patient findByIdPatient(Integer p_id) {
        return patientDao.findByIdPatient(p_id);
    }

    @Override
    @Transient
    public void insertPatient(Patient patient) {
        patientDao.insertPatient(patient);
    }

    @Override
    @Transient
    public void deleteByIdPatient(Integer p_id) {
        patientDao.deleteByIdPatient(p_id);
    }

    @Override
    @Transient
    public void updatePatient(Patient patient) {
        patientDao.updatePatient(patient);
    }

    @Override
    public List<Patient> doctorFindAllPatient(Integer p_doctor) {
        return patientDao.doctorFindAllPatient(p_doctor);
    }


}
